<%@ page import="cn.gudian.cms.Admin.AdminUser" %>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="layout" content="main"/>
  <title>修改密码</title>
  <script>
    function VerifyData(oldpass, newpass, newpass2, message) {
      if (document.getElementById(oldpass).value.length == 0 || document.getElementById(newpass).value.length == 0 || document.getElementById(newpass2).value.length == 0) {
        alert("请输入完整信息");
        return false;
      }
      var p = document.getElementById(oldpass).value;
      var p1 = document.getElementById(newpass).value;
      var p2 = document.getElementById(newpass2).value;
      var md5p = hex_md5(p);
      var md5p1 = hex_md5(p1);
      var md5p2 = hex_md5(p2);
      document.getElementById(oldpass).value = md5p;
      document.getElementById(newpass).value = md5p1;
      document.getElementById(newpass2).value = md5p2;
      document.changepass.action = "/adminUser/changepassword";
    }
  </script>
  <script type="text/javascript" src="/js/admin/md5-min.js"></script>
</head>
<body>
<div class="nav">
  <span class="menuButton"><a class="home" href="${createLinkTo(dir: '/adminUser')}"><g:message code="home" default="Home"/></a></span>
  <span class="menuButton"><g:link class="list" action="list"><g:message code="adminUser.list" default="AdminUser List"/></g:link></span>
</div>
<div class="body">
  <h1>修改密码</h1>
  <g:if test="${flash.message}">
    <div id="message" class="message"><g:message code="${flash.message}" args="${flash.args}" default="${flash.defaultMessage}"/></div>
  </g:if>
  <g:hasErrors bean="${adminUserInstance}">
    <div class="errors">
      <g:renderErrors bean="${adminUserInstance}" as="list"/>
    </div>
  </g:hasErrors>
  <form method="post" name="changepass" onSubmit="return VerifyData('oldpass','newpass','newpass2','message')">
    <g:hiddenField name="id" value="${adminUserInstance?.id}"/>
    <g:hiddenField name="version" value="${adminUserInstance?.version}"/>
    <div class="dialog">
      <table>
        <tbody>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="userName"><g:message code="adminUser.userName" default="User Name"/>:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'userName', 'errors')}">
            ${fieldValue(bean: adminUserInstance, field: 'userName')}
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="oldpass">原始密码:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'password', 'errors')}">
            <input type="password" id="oldpass" name="oldpass"/>
          </td>
        </tr>
        <tr class="prop">
          <td valign="top" class="name">
            <label for="newpass">新密码:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'password', 'errors')}">
            <input type="password" id="newpass" name="newpass"/>
          </td>
        </tr>
        <tr class="prop">
          <td valign="top" class="name">
            <label for="newpass2">确认新密码:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'password', 'errors')}">
            <input type="password" id="newpass2" name="newpass2"/>
          </td>
        </tr>
        </tbody>
      </table>
    </div>
    <div class="buttons">
      <span class="button"><input type="submit" class="save" value="修改"/></span>
    </div>
  </form>
</div>
</body>
</html>
